import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';

/*
  Generated class for the AirkissProvider provider.

  See https://angular.io/guide/dependency-injection for more info on providers
  and Angular DI.
*/
@Injectable()
export class AirkissProvider {

  private mEncodedData :Int16Array[16384];
  private mLength : number= 0;

  constructor(public http: Http) {
    console.log('Hello AirkissProvider Provider');
  }
  /**
   *
   * @param ssid
   * @param password
   */
  public AirKissEncoder(ssid :string, password:string) {
    /**
     * 初始化 内存区，获取随机数
     */
    let times = 5;
    while (times-- > 0) {
        // leadingPart();
        // magicCode(ssid, password);
        // let i=0;
        // let mRandomChar;
        // var data : string;
        // for (i = 0; i < 15; ++i) {
        //     prefixCode(password);
        //     data = password + mRandomChar + ssid;
        //     let index;
        //     var content: Uint8Array[4];
        //     for (index = 0; index < data.length / 4; ++index) {
        //         //System.arraycopy(data.getBytes(), index * 4, content, 0, content.length);
        //         sequence(index, content);
        //     }

        //     if (data.length % 4 != 0) {

        //         var dl:number=data.length % 4;
        //         var content1: Uint8Array[dl];

        //         //System.arraycopy(data.getBytes(), index * 4, content, 0, content.length);
        //         sequence(index, content);
        //     }
        // }
    }
  }
  /**
   *
   * @param length
   */
  private  appendEncodedData(length : number) : void {
    this.mEncodedData[this.mLength++] = length;
  }
  /**
   *
   */
  private  leadingPart() : void {
    var i:number=0;var j:number=0;
    for (i = 0; i < 50; ++i) {
        for (j = 1; j <= 4; ++j)
            this.appendEncodedData(j);
        }
    }
}
